package com.itheima.comment.controller;

import com.itheima.comment.dto.CommentReplyDto;
import com.itheima.comment.dto.CommentReplyLikeDto;
import com.itheima.comment.dto.CommentReplySaveDto;
import com.itheima.comment.service.ReplyService;
import com.itheima.comment.vo.ReplyVo;
import com.itheima.common.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/comment_repay")
public class ReplyController {

    @Autowired
    private ReplyService replyService;

    /**
     * 发表回复
     * @return
     */
    @PostMapping("/save")
    public ResultVo saveReply(@RequestBody CommentReplySaveDto dto){
        replyService.saveReply(dto);
        return ResultVo.ok();
    }

    /**
     * 点赞回复
     * @return
     */
    @PostMapping("/like")
    public ResultVo like(@RequestBody CommentReplyLikeDto dto){
        replyService.like(dto);
        return ResultVo.ok();
    }

    /**
     * 查询回复列表
     * @return
     */
    @PostMapping("/load")
    public ResultVo loadPage(@RequestBody CommentReplyDto dto){
        List<ReplyVo> voList = replyService.loadPage(dto);
        return ResultVo.ok(voList);
    }
}
